﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Customer.Bussiness_Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ServiceCore;
using Entity;
using Api.Filter;

namespace Customer.Areas.System.Controllers
{
    [ApiController, Area("System"), Route("/[area]/department/[action]"), Customer_Admin]
    public class departmentController : ControllerBase
    {
        private readonly Idepartment_service _service;
        private readonly IToole_DI _tool;
        public departmentController(Idepartment_service service, IToole_DI tool)
        {
            _service = service;
            _tool = tool;
        }
        /// <summary>
        /// 获取部门列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultObjModel get_list()
        {
            var result = _service.get_list();
            return result;
        }
        /// <summary>
        ///  保存部门信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultModel save_model(rk_department query)
        {
            _tool.di_es.Add_Log("=====保存部门信息_请求====" + Newtonsoft.Json.JsonConvert.SerializeObject(query), "/API_Menu");
            var result = _service.save_model(query);
            _tool.di_es.Add_Log("=====保存部门信息_结果====" + Newtonsoft.Json.JsonConvert.SerializeObject(result), "/API_Menu");
            return result;
        }
        /// <summary>
        /// 根据ID获取单条菜单信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel get_model(string dep_id)
        {
            var result = _service.get_model(dep_id);
            return result;
        }
        /// <summary>
        /// 删除部门信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultModel del_item(string dep_id)
        {
            _tool.di_es.Add_Log("=====删除部门信息_请求====" + dep_id, "/API_Menu");
            var result = _service.del_item(dep_id);
            _tool.di_es.Add_Log("=====删除部门信息_结果====" + Newtonsoft.Json.JsonConvert.SerializeObject(result), "/API_Menu");
            return result;
        }
    }
}